﻿@model Nop.Plugin.Misc.RFQ.Models.Admin.AddProductModel

@using Nop.Core.Domain.Catalog

@{
    Layout = "_AdminLayout";
    //page title
    ViewBag.PageTitle = string.Format(T("Plugins.Misc.RFQ.AdminRequest.Products.AddNew.Title2").Text, Model.Name, Model.QuoteId);
    //active menu item (system name)
    NopHtml.SetActiveMenuItemSystemName(RfqDefaults.RequestsAdminMenuSystemName);
}

@*we add enctype = "multipart/form-data" because "File upload" attribute control type requires it*@

<form asp-controller="RfqAdmin" asp-action="AddProductDetails" asp-route-productId="@Model.ProductId" asp-route-QuoteId="@Model.QuoteId" enctype="multipart/form-data" method="post" id="product-details-form">
    
    <div asp-validation-summary="All"></div>

    <div class="content-header clearfix">
        <h1 class="float-left">
            @string.Format(T("Plugins.Misc.RFQ.AdminRequest.Products.AddNew.Title2").Text, Model.Name, Model.QuoteId)
            <small>
                <i class="fas fa-arrow-circle-left"></i>
                <a asp-action="AdminQuote" asp-route-id="@Model.QuoteId">@T("Plugins.Misc.RFQ.AdminQuote.Products.AddNew.BackToQuote")</a>
            </small>
        </h1>
        <div class="float-right">
            &nbsp;
        </div>
    </div>

    <section class="content">
        <div class="container-fluid">
            @if (Model.Warnings.Count > 0)
            {
                <div class="callout callout-danger">
                    <ul>
                        @foreach (var warning in Model.Warnings)
                        {
                            <li>@warning</li>
                        }
                    </ul>
                </div>
            }

            <div class="form-horizontal">
                <div class="cards-group">
                    @if (Model.ProductType == ProductType.SimpleProduct)
                    {
                        <div class="card card-default">
                            <div class="card-body">
                                <div class="form-group row">
                                    <div class="col-md-3">
                                        <nop-label asp-for="UnitPriceInclTax" />
                                    </div>
                                    <div class="col-md-9">
                                        <nop-editor asp-for="UnitPriceInclTax" />
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <div class="col-md-3">
                                        <nop-label asp-for="Quantity" />
                                    </div>
                                    <div class="col-md-9">
                                        <nop-editor asp-for="Quantity" />
                                    </div>
                                </div>
                            </div>
                        </div>

                        var dataDict = new ViewDataDictionary(ViewData) { new("productId", Model.ProductId) };
                        @await Html.PartialAsync("_ProductAddAttributes.cshtml", Model.ProductAttributes, dataDict)
                        
                        <div class="card card-default">
                            <div class="card-body">
                                <div class="form-group row">
                                    <div class="col-md-9 offset-md-3">
                                        <button type="submit" class="btn btn-primary">
                                            @T("Plugins.Misc.RFQ.AddNewProduct")
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    }
                    else if (Model.ProductType == ProductType.GroupedProduct)
                    {
                        <div class="card card-default">
                            <div class="card-body">
                                Grouped products are not currently supported for adding to the quote
                            </div>
                        </div>
                    }
                    else
                    {
                        <div class="card card-default">
                            <div class="card-body">
                                This product type (unknown) is not currently supported for adding to the quote
                            </div>
                        </div>
                    }
                </div>
            </div>
        </div>
    </section>
    <input asp-for="QuoteId" type="hidden" />
</form>